package sc.vo;

import java.io.Serializable;

public class Student implements Comparable<Student>, Serializable{
	private int stdNo;
	private String stdName;
	private int kor;
	private int eng;
	private int math;
	
	public Student() {
		
	}

	public Student(int stdNo, String stdName) {
		this.stdNo = stdNo;
		this.stdName = stdName;
	}

	public Student(int stdNo, String stdName, int kor, int eng, int math) {
		this.stdNo = stdNo;
		this.stdName = stdName;
		this.kor = kor;
		this.eng = eng;
		this.math = math;
	}
	
	public int getStdNo() {
		return stdNo;
	}

	public String getStdName() {
		return stdName;
	}

	public int getKor() {
		return kor;
	}

	public int getEng() {
		return eng;
	}

	public int getMath() {
		return math;
	}

	public void setStdNo(int stdNo) {
		this.stdNo = stdNo;
	}

	public void setStdName(String stdName) {
		this.stdName = stdName;
	}

	public void setKor(int kor) {
		this.kor = kor;
	}

	public void setEng(int eng) {
		this.eng = eng;
	}

	public void setMath(int math) {
		this.math = math;
	}

	public int totalScore(){
		return kor + eng + math;
	}
	
	public double totalAvg() {
		return totalScore() / 3.0;
	}

	@Override
	public String toString() {
		return String
				.format("%3s\t%5s\t%3s\t%3s\t%3s\t%3s\t%6.2f",
						stdNo, stdName, kor, eng, math, totalScore(), totalAvg());
	}

	@Override
	public boolean equals(Object obj) {
		Student std = (Student) obj;
		if(obj instanceof Student) {
			return stdNo == std.stdNo &&
					stdName.equals(std.stdName);
		}
		return false;
	}

	@Override
	public int compareTo(Student o) {
		return stdNo - o.stdNo;
	}
}